﻿<div>

<script type="text/javascript">
    $(function () {
        var t = $("#t1").treegrid({
            title: 'test treegrid',
            width: 900,
            height: 400,
            method: "get",
            url: "treegrid/treegrid-data.json",
            idField: 'id',
            treeField: 'name',
            remoteSort: false,
            frozenColumns: [[
                { field: 'ck', checkbox: true },
                { field: 'id', title: 'ID(id)', width: 80, sortable: true }
            ]],
            columns: [[
                { field: 'name', title: '名称(name)', width: 180, sortable: true },
                { field: 'age', title: '年龄(age)', width: 120, sortable: true },
                { field: 'weight', title: '体重(weight)', width: 120, sortable: true },
                { field: 'size', title: 'Size(size)', width: 140 },
                { field: 'date', title: '日期(date)', width: 140, sortable: true },
                { field: 'undefined', title: '测试(不存在的字段)', width: 140 }
            ]],
            enableHeaderClickMenu: false,
            enableHeaderContextMenu: false,
            enableRowContextMenu: false
        });

        var array = $.array.filter(t.treegrid("getColumns", "all"), function (val) { return val.field && val.title ? true : false; }),
            cc = $("#select1").combobox({ width: 120, valueField: "field", textField: "title", data: array });

        $("#clear").click(function () { cc.combobox("clear"); });

        $("#Button1").click(function () {
            var field = cc.combobox("getValue"), val = $("#Text1").val();
            t.treegrid("livesearch", field ? { field: field, value: val} : val);
        });
    });
</script>

<h2>jEasyUI TreeGrid Extensions - 高亮关键词查找</h2>
<p>该部分扩展由文件 jeasyui.extensions.treegrid.js 实现。</p>
<hr />
<p>
    该 DEMO 演示 datagrid 的高亮关键词查找功能扩展；<br />
    如果未设定列，将查找所有列；<br />
    如果未设定任何关键词，则取消之前的高亮显示效果。
</p>
<input id="Button1" type="button" value="高亮关键词查找" />
请选择要查找的列：<select id="select1"></select><a id="clear" class="easyui-linkbutton easyui-tooltip" data-options="plain: true, iconCls: 'icon-undo', content: '清空'" ></a>
请选择要查找的关键词：<input id="Text1" type="text" />
<br /><br />
<table id="t1"></table>

</div>